package 统计算法.哪种连续子字符串更长;

public class nzlxzzfcgc {
    public static void main(String[] args) {

    }
    public static boolean checkZeroOnes(String s) {
        int countOne = 0;
        int MaxOne = 0;
        int countZero = 0;
        int MaxZero = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '1'){
                ++countOne;
                countZero = 0;
            }else {
                ++countZero;
                countOne = 0;
            }
            if (MaxOne < countOne){
                MaxOne = countOne;
            }
            if (MaxZero < countZero){
                MaxZero = countZero;
            }
        }
        return MaxOne > MaxZero;

    }
}
